
wx - Page({
  /**
   * 页面的初始数据
   */
  data: {
    // 轮播图
    swiperList: [],
    // 导航数组
    SellFast: [],
    // 楼层数据
    floorList: [],
    images:[{
        id: 0,
        value: "热销",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/热销.png',
        classify_id:0
      },{
        id: 1,
        value: "服装",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/服装.png',
        classify_id:5
      },{
        id: 2,
        value: "图书",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/图书.png',
        classify_id:9
      },{
        id: 3,
        value: "生活",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/生活.png',
        classify_id:1
      },{
        id: 4,
        value: "手机",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/手机.png',
        classify_id:3
      },{
        id: 5,
        value: "超市",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/超市.png',
        classify_id:6
      },{
        id: 6,
        value: "护肤",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/护肤.png',
        classify_id:2
      },{
        id: 7,
        value: "数码",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/数码.png',
        classify_id:3
      },{
        id: 8,
        value: "箱包",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/箱包.png',
        classify_id:5
      },{
        id: 9,
        value: "更多",
        image_url: 'cloud://xiaochengxu-2gcm02cv74f2b2b8.7869-xiaochengxu-2gcm02cv74f2b2b8-1304174669/更多.png'
      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    this.getSwiperList()
    this.getGoodsSellFast() 
  },
  getSwiperList() {
   wx.cloud.database().collection('swiperList')
   .get()
   .then(res=>{
     this.setData({
      swiperList:res.data
     })
   })
  },

  getGoodsSellFast() {
    let len = this.data.SellFast.length
    console.log(len);
    wx.cloud.database().collection('goodsDetail').where({
      isFastSell:true
    })
    .skip(len)
    .limit(6)
    .get()
    .then(res=>{
      console.log(res);
      this.setData({
        SellFast:this.data.SellFast.concat(res.data)
      })
    })
  },

  gotoCategory(e) {
     console.log(e.currentTarget.dataset.classifyid);
     let index= e.currentTarget.dataset.index
     let classifyID=e.currentTarget.dataset.classify_id
     if(index==9) {
       wx.switchTab({
         url: '/pages/category/category',
       })
     }
      
  },
  onReachBottom:function(e) {
    // console.log('到底了');
    this.getGoodsSellFast()
  }

})
